<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
    <title>前端路由</title>
    <style>
        *{
            margin: 0;
            padding:0;
            border: 0;
        }
        html,body{
            height:100%;
        }

        .router-warp{
            height:100%;
            position: relative;
        }
        .router-page{
            position: absolute;
            left:0;
            top:0;
            width:100%;
            height:100%;
        }
        .pageIn{
            animation: pageIn .5s;
        }
        .pageHide{
            animation: pageHide .5s forwards;
        }
        .pageOut{
            animation:pageOut .5s forwards;
        }
        .pageShow{
            animation:pageShow .5s;
        }
        @keyframes pageIn{
            from{
                transform:translate3d(100%,0,0);
            }
            to{
                transform:translate3d(0,0,0);
            }
        }
        @keyframes pageOut{
            from{
                transform:translate3d(0,0,0);
            }
            to{
                transform:translate3d(100%,0,0);
            }
        }
        @keyframes pageHide{
            from{
                transform:translate3d(0,0,0);
            }
            to{
                transform:translate3d(-30%,0,0)
            }
        }
        @keyframes pageShow{
            from{
                transform:translate3d(-30%,0,0);
            }
            to{
                transform:translate3d(0,0,0)
            }
        }



        .mod-a{
            height:100%;
            background: #2bad66;
        }
        .mod-b{
            height:100%;
            background: #2e8ded;
        }
        .mod-c{
            height:100%;
            background: #7b72e9;
        }
    </style>
</head>
<body>
<div class="router-warp"></div>


<script type="text/html" id="aPage">
    <div class="mod-a">
        <h1>A页面</h1>
        <p><a href="#/list">去List页面</a></p>
        <p><a href="#/desc">去Desc页面</a></p>
    </div>
</script>
<script type="text/html" id="bPage">
    <div class="mod-b">
        <h1>B页面</h1>
        <p><a href="#/index">去Index页面</a></p>
        <p><a href="#/desc">去Desc页面</a></p>
    </div>
</script>
<script type="text/html" id="cPage">
    <div class="mod-c">
        <h1>C页面</h1>
        <p><a href="#/index">去Index页面</a></p>
        <p><a href="#/list">去List页面</a></p>
    </div>
</script>

<script src="../js/jquery.min.js"></script>
<script src="../js/JsRouter.js"></script>
<script>
    JsRouter.map([{
            path:'/index',//路由路径
            template:'aPage',//路由模板
            join:'aJoin',//进入此路由执行
            back:'aBack',//退回此路由执行
            async:'../js/a.js'//异步加载
        },
        {
            path:'/list',
            template:'bPage',
            join:'bJoin',
            back:'bBack'
        },
        {
            path:'/desc',
            template:'cPage',
            join:'cJoin',
            back:'cBack',
            async:'../js/c.js'
        }
    ]);
    JsRouter.render();

    var bJoin=function(){
        console.log('执行bJoin方法');
    };
</script>
</body>
</html>
